package com.ruoyi.device.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.TRoomMapper;
import com.ruoyi.device.domain.TRoom;
import com.ruoyi.device.service.ITRoomService;

import static com.ruoyi.common.security.utils.SecurityUtils.getLoginUser;

/**
 * 房间Service业务层处理
 * 
 * @author li
 * @date 2025-09-22
 */
@Service
public class TRoomServiceImpl implements ITRoomService 
{
    @Autowired
    private TRoomMapper tRoomMapper;

    /**
     * 查询房间
     * 
     * @param id 房间主键
     * @return 房间
     */
    @Override
    public TRoom selectTRoomById(String id)
    {
        return tRoomMapper.selectTRoomById(id);
    }

    /**
     * 查询房间列表
     * 
     * @param tRoom 房间
     * @return 房间
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<TRoom> selectTRoomList(TRoom tRoom)
    {
        return tRoomMapper.selectTRoomList(tRoom);
    }

    /**
     * 新增房间
     * 
     * @param tRoom 房间
     * @return 结果
     */
    @Override
    public int insertTRoom(TRoom tRoom)
    {
        tRoom.setCreateBy(getLoginUser().getUsername());
        tRoom.setCreateTime(DateUtils.getNowDate());
        return tRoomMapper.insertTRoom(tRoom);
    }

    /**
     * 修改房间
     * 
     * @param tRoom 房间
     * @return 结果
     */
    @Override
    public int updateTRoom(TRoom tRoom)
    {
        tRoom.setUpdateBy(getLoginUser().getUsername());
        tRoom.setUpdateTime(DateUtils.getNowDate());
        return tRoomMapper.updateTRoom(tRoom);
    }

    /**
     * 批量删除房间
     * 
     * @param ids 需要删除的房间主键
     * @return 结果
     */
    @Override
    public int deleteTRoomByIds(String[] ids)
    {
        return tRoomMapper.deleteTRoomByIds(ids);
    }

    /**
     * 删除房间信息
     * 
     * @param id 房间主键
     * @return 结果
     */
    @Override
    public int deleteTRoomById(String id)
    {
        return tRoomMapper.deleteTRoomById(id);
    }
}
